package com.huawei.springboot2023.business.goodstype.controller;

import com.huawei.springboot2023.business.goodstype.dto.Goodstype;
import com.huawei.springboot2023.business.goodstype.service.IGoodstypeService;
import com.huawei.springboot2023.business.user.service.IUserService;
import com.huawei.springboot2023.core.dto.MyResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhouChengYang
 * @since 2023-04-07
 */
@RestController
@Slf4j
@RequestMapping("/goodstype")
public class GoodstypeController {

    @Resource(name = "goodstypeServiceImpl")
    private IGoodstypeService goodstypeService;

    /**
     * 获取物资类型表的所有数据
     * @return
     */
    @GetMapping("/getAllGoodsType")
    @ResponseBody
    public MyResult getAllGoodsType(){
        log.debug("新增台账----获取物资类型");
        MyResult result = new MyResult();
        List<Goodstype> list = goodstypeService.list();
        if (list.size() > 0){
            result.setMsg("查询物资类型成功");
            result.setData(list);
        }else {
            result.setCode("9999");
            result.setMsg("查询失败");
        }
        return result;
    }

}
